home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / system / Timer.st < prev    next >
Encoding:
Text File  |  2004-01-31  |  1.5 KB  |  75 lines

  1. "----------------------------------------------------------------------"
  2. " TimerDevice Class is derived from abstract Device Class.             "
  3. ""
  4. "  WARNING:  You should know what you're doing to the Amiga OS before  "
  5. "            messing with this Class, or any other System Class!       "
  6. " ---------------------------------------------------------------------"
  7.  
  8. Class TimerDevice :Device ! private timerType !
  9. [
  10.    stop
  11.  
  12.       <primitive 228 2 private> "Kill Timer (you still have to close it)."
  13. |
  14.    startWithSecs: s withMicros: m
  15.  
  16.       <primitive 228 3 private s m>
  17. |
  18.    delaySeconds: s micros: m
  19.  
  20.       <primitive 228 4 private s m>
  21. |
  22.    test
  23.  
  24.       ^ <primitive 228 5 private>
  25. |
  26.    getTimerType
  27.  
  28.       ^ timerType
  29. |
  30.    getSeconds
  31.  
  32.       ^ <primitive 228 6 private>
  33. |
  34.    getMicros
  35.  
  36.       ^ <primitive 228 7 private> 
  37. |
  38.    setSeconds: s micros: m
  39.  
  40.       ^ <primitive 228 8 private s m>
  41. |
  42.    compare: s micros: m toSeconds: s2 micros: m2
  43.  
  44.       " if      t1 >  t2, return -1
  45.       * else if t1 <  t2, return +1
  46.       * else if t1 == t2, return 0
  47.       "
  48.  
  49.       ^ <primitive 228 9 s m s2 m2>
  50. |
  51.    getEClockHigh
  52.  
  53.       ^ <primitive 228 10 private>
  54. |
  55.    getEClockLow
  56.  
  57.       ^ <primitive 228 11 private>
  58. |
  59.    openTimer: timerName type: newTimerType seconds: secs  micros: micros
  60.  
  61.       private   <- <primitive 228 1 newTimerType secs micros timerName>. "Setup Timer"
  62.  
  63.       timerType <- newTimerType.
  64.  
  65.       ^ self
  66. |
  67.    close
  68.  
  69.       <primitive 228 0 private>.   "Close the Timer"
  70.  
  71.       <primitive 250 5 0 private>. "Once closed, it's dead!"
  72.       
  73.       ^ nil             
  74.